package zerous.infinite.core.entity;

import zerous.infinite.core.*;
import zerous.infinite.*;
import com.badlogic.gdx.graphics.g2d.*;
import zerous.infinite.util.*;

public class Enemy extends Entity
{
	Entity target;
	public Enemy(Entity target, int x, int y) {
		this.target = target;
		velocity.set(0.5f, 0.5f);
		position.set(x, y);
		texture = new Sprite(Assets.TEST);
	}

	@Override
	public void draw(Batch batch) {
		super.draw(batch);
		float distance = MathUtil.distance(target.position, position);
		if (distance > 0.2) {
			float dx = target.position.x - position.x;
			float dy = target.position.y - position.y;
			direction.set(dx/distance, dy/distance);
		} else { 
			direction.setZero();
		}
		position.add(velocity.x * direction.x, velocity.y * direction.y);
		
		texture.setPosition(position.x, position.y);
		
		texture.draw(batch);
	}
}
